const axios = require('axios');
const username = '这个可以看浏览器地址栏中的用户名,不一定是登录账号名';
const token = 'github_pat_11ACxxxxxxxxxxxxxxxxxxx';

// 列出所有仓库的名称
// axios.get('https://api.github.com/user/repos', {
//     auth: {
//         username: username,
//         password: token,
//     },
// }).then(response => {
//     const repositories = response.data;
//     for (const repository of repositories) {
//         console.log(repository.name);
//     }
// }).catch(error => {
//     console.error(error);
// });
axios.get('https://api.github.com/user/repos', {
    auth: {
        username: username,
        password: token,
    },
}).then(response => {
    const repositories = response.data;
    const deletePromises = repositories.map(repo => {
        // 打印仓库名称
        // console.log(repo.name);
        return axios.delete(`https://api.github.com/repos/${username}/${repo.name}`, {
            auth: {
                username: username,
                password: token,
            },
        });
    });
    return Promise.all(deletePromises);
}).then(() => {
    console.log('所有仓库都已删除!');
}).catch(error => {
    console.error(error);
});
